package meng.spring.test19.springaopapi;

import java.lang.reflect.Method;

import org.springframework.aop.AfterReturningAdvice;

/**
 * 成功返回后通知
 * 
 * @author mengzhang6
 *
 */
public class MyAfterReturningAdvice implements AfterReturningAdvice {
	private int count;

	public int getCount() {
		return count;
	}

	public void afterReturning(Object returnValue, Method method,
			Object[] args, Object target) throws Throwable {
		// 可以访问返回值（但不能修改）、被调用方法、方法的参数和目标
		// 如果抛出异常，将会抛出拦截器链，替代返回值
		System.out.println("MyAfterReturningAdvice - afterThrowing");
		System.out.println("MyAfterReturningAdvice-"
				+ target.getClass().getName());
		System.out.println("MyAfterReturningAdvice-" + method.getName());
		System.out.println("MyAfterReturningAdvice-" + args);
		++count;
	}

}
